#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
struct Node {
    int d, v, a;
} x[N];
struct Node1 {
    int l, r;
    bool operator< (const Node1 &B) const {
        if (l == B.l) return r < B.r;
        return l < B.l;
    }
} a[N];
int usep[N];
int p[N];
double calcspeed(int v, int a, int s) {
    if (v*v*1.0 + 2.0 * a * s <= 0) return 0;
    return sqrt(v*v*1.0 + 2.0 * a * s);
}
bool can[N];
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T--) {
        memset(can, 0, sizeof can);
        memset(usep, 0, sizeof usep);
        int n, m, L, V;
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for (int i = 1; i <= n; ++i) {
            int d, v, a;
            scanf("%d%d%d", &d, &v, &a);
            x[i] = {d, v, a};
        }
        for (int i = 1; i <= m; ++i)
            scanf("%d", p + i);
        sort(p + 1, p + m + 1);
        int ct = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (x[i].d > p[j]) continue;
                if (calcspeed(x[i].v, x[i].a, p[j] - x[i].d) > V*1.0) {
                    ++ct;
                    a[i].l = p[j];
                    break;
                }
            }
            if (a[i].l == 0) a[i].l = 0x3f3f3f3f;
        }
        for (int i = 1; i <= n; ++i) {
            if (a[i].l == 0x3f3f3f3f) continue;
            for (int j = m; j > 0; --j) {
                if (calcspeed(x[i].v, x[i].a, p[j] - x[i].d) > V*1.0) {
                    a[i].r = p[j];
                    break;
                }
            }
        }

        sort(a + 1, a + n + 1);
        for (int i = 1; i <= n; ++i) {
            for (int j = i+1; j <= n; ++j) {
                if (a[i].l >= a[j].l and a[i].r <= a[j].r and a[i].r >= a[j].l and a[i].l <= a[j].r) can[j] = true;
            }
        }
        int ct1 = 0, ctu = 0;
        for (int i = 1; i <= n; ++i) {
            if (can[i]) continue;
            if (a[i].l == 0x3f3f3f3f) continue;
            if (a[i].l == a[i-1].l) continue;
            bool flag = true;
            for (int j = 1; j <= ctu; ++j) {
                if (a[i].l <= usep[j] and usep[j] <= a[i].r) {
                    flag = false;
                    break;
                }
            }
            if (!flag) continue;
            for (int j = m; j > 0; --j) {
                if (a[i].l <= p[j] and p[j] <= a[i].r) {
                    ++ct1;
                    usep[++ctu] = p[j];
                    break;
                }
            }
        }
        printf("%d %d\n", ct, m - ct1);
    }
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15*/
